package com.lie.prepare.sort;

import org.junit.Test;

import static com.lie.prepare.sort.util.MyArrayHelper.*;
/**
 * Created by lie on 2018/4/18.
 */
public class BubbleSort {

    public static void doSort(){
        int[] array = getArray();
        for (int outI = array.length-1; outI >=0; outI--) {
            boolean isOk = true;
            for (int i = 0; i < outI; i++) {
                if (array[i] > array[i+1]){
                    int temp = array[i];
                    array[i] = array[i+1];
                    array[i+1] = temp;
                    isOk = false;
                }
            }

            if (isOk)
                break;
        }
        printArraySort(array);
    }

    @Test
    public void test(){
        doSort();
    }


}
